using AIFSCMS.Infrastructure.Repositories;
using AIFSContentManagementSystem;
using AIFSContentManagementSystem.Articles;
using AIFSContentManagementSystem.Criteria;
using AIFSDataAccessLayer;

namespace AIFSCMSFacade
{
    public static class AifsCmsServiceBuilder
    {
        /// <summary>
        /// Creates an IArticleService for the provided data context. DisableLazyLoad flag specifies if lazy loading should be
        /// enabled. For disconnected (web) applications set this to true if you are not using DTO. Because when creating DTO the required
        /// items are automatically loaded as required.
        /// </summary>
        public static ArticleService GetArticleService(IDataExecutionContext DataExecutionContext, bool DisableLazyLoad)
        {
            IRepositoryMap map = new RepositoryMap(DataExecutionContext);
            map.DisableLazyLoad = DisableLazyLoad;
            
            IParser parser = new Parser();
            ArticleService service = new ArticleService(map, parser);
         
            return service;
        }

        /// <summary>
        /// Creates an ICriteriaService for the provided data context. DisableLazyLoad flag specifies if lazy loading should be
        /// enabled. For disconnected (web) applications set this to true if you are not using DTO. Because when creating DTO the required
        /// items are automatically loaded as required.
        /// </summary>
        public static CriteriaService GetCriteriaService(IDataExecutionContext DataExecutionContext, bool DisableLazyLoad)
        {            
            IRepositoryMap map = new RepositoryMap(DataExecutionContext);
            map.DisableLazyLoad = DisableLazyLoad;

            CriteriaService service = new CriteriaService(map);

            return service;
        }
    }
}
